<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div id="menuContent2" class="menuContent2" style="display: none; position: absolute;">
						<ul id="organSelectTree2" class="ztree" style="margin-top: 0;width: 200px;"></ul>
					</div>
					<script src="${cxt !}/sb/js/jquery.form.js" type="text/javascript" charset="utf-8"></script>
			<script type="text/javascript">
			var setting = {
				async : {
					enable : true,
					url : '${cxt!}/common/getOrgenTree',
					autoParam : [ "id=ids" ],//, "name=n", "level=lv"
					type : "post"
				},
				view : {
					dblClickExpand : false
				},
				data : {
					simpleData : {
						enable : true
					}
				},
				callback : {
					onClick : onClick2,
					onAsyncSuccess : organTreeOnAsyncSuccess2
				}
			};
			var flag = 0;
			function organTreeOnAsyncSuccess2(event, treeId, msg) {
				
				if(flag == 0){
					var organTree = $.fn.zTree.getZTreeObj("organSelectTree2");
					var nodes = organTree.getNodes();
					initMangerSelect2(nodes[0].id);
					//initProductStockTable(nodes[0].id);
					flag = 1;
				}
			}
			function onClick2(e, treeId, treeNode) {
				initMangerSelect2(treeNode.id);
				var zTree = $.fn.zTree.getZTreeObj("organSelectTree2");
				var path = "";
				var sNodes = zTree.getSelectedNodes();
				if (sNodes.length > 0) {
					var node = sNodes[0].getPath();
					for(var i =0;i<node.length;i++){
						path += node[i].name + "/"
					}
				}
				var cityObj = $("#organ2");
				cityObj.attr("value", path);
				$("#organIds2").attr("value", treeNode.id);
				hideMenu2();
				
			}
			function showMenu2() {
				
				var cityObj = $("#organ2");
				var cityOffset = $("#organ2").offset();
				
				$("#menuContent2").css({
					left : cityOffset.left + "px",
					top : cityOffset.top + cityObj.outerHeight() + "px"
				}).slideDown("fast");
		
				$("body").bind("mousedown", onBodyDown2);
				
			}
			function hideMenu2() {
				$("#menuContent2").fadeOut("fast");
				$("body").unbind("mousedown", onBodyDown2);
			}
			function onBodyDown2(event) {
				if (!(event.target.id == "menuBtn"
						|| event.target.id == "menuContent2" || $(event.target)
						.parents("#menuContent2").length > 0)) {
					hideMenu2();
				}
			}
			$.fn.zTree.init($("#organSelectTree2"), setting);
			//初始化市场负责人下拉框
			function initMangerSelect2(ids){
				var url = "/common/getUsersByOrgan";
				var param = {
						'ids':ids
					};
				var data = common_ajax.ajaxFunc(url,param,"json");
				/*data.unshift({  
                     'ids': '-1',  
                     'name': '-请选择-'  
                 });*/
				$('#organMangerIds2').combobox({
				    data:data,
				    valueField:'ids',
				    textField:'name',
				    multiple:true,		    
				    onLoadSuccess : function(){  		    	
				    	 var val = $(this).combobox('getData');  
		                   /* for (var item in val[0]) {  
		                        if (item == 'ids') {  
		                            $(this).combobox('select', val[0][item]);  
		                        }  
		                    }*/
			        }
				});
			}
		</script>
</body>
</html> 